//swiper轮播
var swiper = new Swiper('.swiper-container', {
    loop:true,
    autoplay: {
     delay: 3000,
     stopOnLastSlide: false,
     disableOnInteraction: true
     }
});

//返回顶部
var t = document.querySelector("#fh");
window.onscroll = function () {
    if (document.documentElement.scrollTop > 1000){
        t.style.display = "block";
    }else {
        t.style.display = "none";
    }
};
t.addEventListener('click',function () {
    window.scrollTo({
        top:0,
        behavior:'smooth'
    })
});


//首页选项卡
var te = document.querySelectorAll(".te > li");
var da = document.querySelectorAll(".da > div");

for (var i = 0;i < te.length;i++){
    te[i].index = i;
    te[i].addEventListener('click',function(){
        for (var k = 0;k < te.length;k++){
            te[k].classList.remove('active');
            da[k].classList.remove('active');
        }
        this.classList.add('active');
        console.log(this.index);
        da[this.index].classList.add('active');
    })
}


//json数据
var vm = new Vue({
    el: "#app",
    data: {
        message: '正在请求数据!'
    },

    mounted() {
        axios
            .get('json/package.json')
            .then(response => (this.message = response.data.link2s))
            .catch(function(error) {
                console.log(error)
            })
    }

});


//产品中心选项卡
var subnav = document.querySelectorAll(".subnav > li");
var tab = document.querySelectorAll(".tab > div");

for (var i = 0;i < subnav.length;i++){
    subnav[i].index = i;
    subnav[i].addEventListener('click',function(){
        for (var k = 0;k < subnav.length;k++){
            subnav[k].classList.remove('act');
            tab[k].classList.remove('act');
        }
        this.classList.add('act');
        console.log(this.index);
        tab[this.index].classList.add('act');
    })
}



//点击事件
var make = document.querySelector(".make");
var sj = document.querySelector(".sj");

var b = true;
make.addEventListener("click",function () {

    if(b){   console.log("谁在上面？");
        sj.style.display = "block";
        document.querySelector("nav .container .sj .loc").style.display = "block"


    }else{
        sj.style.display = "none";
        document.querySelector("nav .container .sj .loc").style.display = "none"

    }

    b = !b;
});
